<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>

    <link href="./assets/styles/default.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>

	<style>
		.tLeft {
			clear: both;
			float:left;width:48%;
		}
		.tRight {
			float:right;width:48%;
		}
		h5 {
			padding:10px;
			margin: 0;
			text-align: left;
			background-color: #f5f5f5;
			border-bottom: 3px double #e5e5e5;
			font-size: 14px;
		}
		#totalTable th {
			text-align: right !important;
		}

	</style>
	<script type="text/javascript">
	function check(tableid)
	{
		var ret=true;
		//checkempty
		if(tableid=="t1"||tableid=="t2"||tableid=="t3"||tableid=="t4")
		{
			$("#"+tableid+" input:text").each(
					function(i,el){
						if($(this).val()=="")
						{
							alert("入力してください");
							$(this).focus();ret=false;return false;
						}
					}
			);
		}
		if(!ret) return ret;

		//checknumbers
		if(tableid=="t3"||tableid=="t4")
		{
			$("#"+tableid+" input[chk='num']").each(
					function(i,el){
						if(!$.isNumeric($(this).val()))
						{
							alert("半角整数で入力してください");
							$(this).focus();ret=false;return false;
						}
					}
			);
		}
			if(!ret) return ret;

		//checkdate
		if(tableid=="t5")
		{
			$("#"+tableid+" input[chk='date']").each(
					function(i,el){
						if(!isDate($(this).val()))
						{
							alert("YYYY-MM-DD で入力してください");
							$(this).focus();ret=false;return false;
						}
					}
			);
		}


		return ret
	}

	function checkall()
	{
		if(!check("t1"))return false;
		if(!check("t2"))return false;
		if(!check("t3"))return false;
		if(!check("t4"))return false;
		if(!check("t5"))return false;
		if(!check("t6"))return false;s
		return false;
	}

	function isDate(value){
		var ereg = /^(\d{1,4})(-|\/)(\d{1,2})(-|\/)(\d{1,2}) {1,10}(0\d{1}|1\d{1}|2[0-3]):[0-5]\d{1}:([0-5]\d{1})$/;
		var r = value.match(ereg);
		if (r == null) {
		return false;
		}
		var d = new Date(r[1], r[3] - 1, r[5]);
		var result = (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[5]);
		return result;
	}
	</script>
</head>
<body>

{{$zhead}}
<div id="container">
{{$zmenu}}

<center><span style="color:red;">{{$errmsg}}</span></center>
    <article>
    	<h2><span>&nbsp;</span>注文管理<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
				<li class="active"><a href="Home_OrderManage_index.html"><span>履歴検索</span></a></li>
				<li><a href="Home_order_summary.html"><span>売上集計</span></a></li>
				<li><a href="Home_order_setting.html"><span>基本設定</span></a></li>
			</ul>
        </nav>
		<section id="content">
			<h3>注文情報参照</h3>
			<ul class="clear btns float-right t10 b10" style="position:relative;top: 5px;right: -15px;">
				<li class="btn single c"><a href="{{'Home/OrderManage/index'|U}}" o>戻る</a></li>
			</ul>
			<form name="fm" id="fm" action="{{'Home/OrderRefer/updateall'|U}}" method="post" enctype="multipart/form-data" class="clear">
			<input name="order_id" type="hidden" value="{{$orderrow.order_id}}">
				<h4>
					<span>&nbsp;</span>
					注文No.{{$orderrow.order_number}}
					&nbsp;&nbsp;
					{{$orderrow.order_time|date_format:"%Y/%m/%d %H:%M:%S"}}
				</h4>

				<ul class="clear btns float-right t10 b10" style="position:relative;right: -15px;">
					<li class="btn left c"><a href="javascript:" onclick="$('#fm').attr('action','{{'Home/OrderRefer/updatesended'|U}}');$('#fm').submit();">配送完了</a></li>
					<li class="btn right c"><a  onclick="$('#fm').attr('action','{{'Home/OrderRefer/updatedelete'|U}}');$('#fm').submit();">削除</a></li>
				</ul>

				<div class="tLeft">
					<h5>注文基本情報</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>注文日時</th>
								<td>{{$orderrow.order_time|date_format:"%Y/%m/%d %H:%M:%S"}}</td>
							</tr>
							<tr>
								<th>注文番号</th>
								<td>{{$orderrow.order_number}}</td>
							</tr>
							<tr>
								<th>状態</th>
								<td>{{if $orderrow.order_status eq 1}}未確定{{elseif $orderrow.order_status eq 2}}確定{{elseif $orderrow.order_status eq 3}}発想済{{elseif $orderrow.order_status eq 4}}キャンセル{{/if}}</td>
							</tr>
							<tr>
								<th>経路</th>
								<td>{{if $orderrow.order_way eq 1}}PC{{elseif $orderrow.order_way eq 2}}スマホ{{/if}}</td>
							</tr>
						</tbody>
					</table>
					<h5>
						請求住所
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="if(!check('t1')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updaterequestaddress'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t1">
						<tbody>
							<tr>
								<th>氏名</th>
								<td><input name="user_name1" type="text" value="{{$orderrow.user_name1}}">
								<input name="user_name2" type="text" value="{{$orderrow.user_name2}}"></td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td><input name="user_office_name" type="text" value="{{$orderrow.user_office_name}}"></td>
							</tr>
							<tr>
								<th>住所</th>
								<td>
								<input name="user_local_name" type="text" value="{{$orderrow.user_local_name}}">
								<input name="user_treet_name" type="text" value="{{$orderrow.user_treet_name}}">
								<input name="user_address" type="text" value="{{$orderrow.user_address}}">
								</td>
							</tr>
							<tr>
								<th>電話番号</th>
								<td><input name="user_tel_number" type="text" value="{{$orderrow.user_tel_number}}"></td>
							</tr>
							<tr>
								<th>E-Mail</th>
								<td><input name="email" type="text" value="{{$orderrow.email}}"></td>
							</tr>
						</tbody>
					</table>
					<h5>支払方法</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>支払方法</th>
								<td>{{$orderrow.pay_content}}</td>
							</tr>
							<tr>
								<th>与信情報</th>
								<td>{{$orderrow.payinfo}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<div class="tRight">
					<h5>会員情報</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>会員氏名</th>
								<td>
								{{$userrow.user_name1|cat:'&nbsp'|cat:$userrow.user_name2}}
								</td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td>{{$userrow.workshop_name}}</td>
							</tr>
							<tr>
								<th>E-Mail</th>
								<td>{{$userrow.email}}</td>
							</tr>
							<tr>
								<th>グループ</th>
								<td></td>
							</tr>
						</tbody>
					</table>
					<h5>
						配送住所
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="if(!check('t2')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updatesendaddress'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t2">
						<tbody>
							<tr>
								<th>氏名</th>
								<td>
								<input name="send_name1" type="text" value="{{$orderrow.send_name1}}">
								<input name="send_name2" type="text" value="{{$orderrow.send_name2}}">
								</td>
							</tr>
							<tr>
								<th>貴医院名・貴技工所名</th>
								<td><input name="send_office_name" type="text" value="{{$orderrow.send_office_name}}"></td>
							</tr>
							<tr>
								<th>住所</th>
								<td>
								<input name="send_local_name" type="text" value="{{$orderrow.send_local_name}}">
								<input name="send_treet_name" type="text" value="{{$orderrow.send_treet_name}}">
								<input name="send_address" type="text" value="{{$orderrow.send_address}}">
								</td>
							</tr>
							<tr>
								<th>電話番号</th>
								<td><input name="send_tel_number" type="text" value="{{$orderrow.send_tel_number}}"></td>
							</tr>
						</tbody>
					</table>
					<h5>
						配送情報
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="if(!check('t5')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updatesended'|U}}');$('#fm').submit();">配送完了</a></li>
						</ul>
					</h5>
					<table class="formTable" id="t5">
						<tbody>
							<tr>
								<th>配送日（時）</th>
								<td><input chk="date" name="sent_datetime" type="text" value="{{$orderrow.sent_datetime|date_format:"%Y/%m/%d %H:%M:%S"}}"></td>
							</tr>
							<tr>
								<th>配送会社</th>
								<td><input name="delivery_company" type="text" value="{{$orderrow.delivery_company}}"></td>
							</tr>
							<tr>
								<th>伝票番号</th>
								<td><input name="delivery_number" type="text" value="{{$orderrow.delivery_number}}"></td>
							</tr>
							<tr>
								<th>コメント</th>
								<td><input name="delivery_app" type="text" value="{{$orderrow.delivery_app}}"></td>
							</tr>
						</tbody>
					</table>
				</div>

				<h4 class="clear">
					<span>&nbsp;</span>注文情報
					<ul class="clear btns float-right" style="position:relative;top: -25px">
						<li class="btn single c"><a href="javascript:" onclick="if(!check('t3')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updategoods'|U}}');$('#fm').submit();">更新</a></li>
					</ul>
				</h4>

				<table id="search_result" class="sortable" style="margin-bottom: 20px;">
					<thead>
						<tr>
							<th class="align-center">商品情報＜コード＞</th>
							<th>単価</th>
							<th>数量</th>
							<th>個別送料</th>
							<th>小計</th>
						</tr>

					</thead>
					<tbody id="t3">
					<input name="goodcount" type="hidden" value="{{$goods|@count}}">
					{{foreach name=goodloop from=$goods item=i}}
						<tr ><input name= "goodid_{{$smarty.foreach.goodloop.index}}" type="hidden" value="{{$i.id}}">
							<td><input name="goods_name_{{$smarty.foreach.goodloop.index}}" type="text" value="{{$i.goods_name}}"></td>
							<td>\<input  chk="num" name="goods_unitprice_{{$smarty.foreach.goodloop.index}}" type="text" value="{{$i.goods_unitprice|string_format:'%.2f'}}"></td>
							<td>\<input  chk="num" name="goods_num_{{$smarty.foreach.goodloop.index}}" type="text" value="{{$i.goods_num}}"></td>
							<td>\0</td>
							<td>\{{$i.goods_unitprice*$i.goods_num|string_format:'%.2f'}}</td>
						</tr>
					{{/foreach}}
					</tbody>
				</table>

				<div class="tLeft">
					<h5>
						その他
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="if(!check('t6')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updateothers'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable">
						<tbody>
							<tr>
								<th>注文コメント</th>
								<td><input name="order_appraise" type="text" value="{{$orderrow.order_appraise}}" ></td>
							</tr>
							<tr>
								<th>社内コメント</th>
								<td><input name="insideappraise" type="text" value="{{$orderrow.insideappraise}}" ></td>
							</tr>
						</tbody>
					</table>
				</div>

				<div class="tRight">
					<h5>
						注文合計
						<ul class="clear btns float-right" style="position:relative;top: -5px">
							<li class="btn single c"><a href="javascript:" onclick="if(!check('t4')){return false;}$('#fm').attr('action','{{'Home/OrderRefer/updatesumprice'|U}}');$('#fm').submit();">更新</a></li>
						</ul>
					</h5>
					<table class="formTable" id="totalTable" >
						<tbody id="t4">
							<tr>
								<th>合計金額</th>
								<td class="align-right">\{{$sumprice|string_format:"%.0f"}}</td>
							</tr>
							<tr>
								<th>送料</th>
								<td class="align-right">\<input  chk="num" name="send_price" type="text" value="{{$orderrow.send_price|string_format:"%.0f"}}"></td>
							</tr>
							<tr>
								<th>手数料</th>
								<td class="align-right">\<input  chk="num" name="buying_price" type="text" value="{{$orderrow.buying_price|string_format:"%.0f"}}"></td>
							</tr>
							<tr>
								<th>税込</th>
								<td class="align-right">\<input  chk="num" name="tax" type="text" value="{{$orderrow.tax|string_format:"%.0f"}}"></td>
							</tr>
							<tr>
								<th>総合計</th>
								<td class="align-right">\{{$sumprice+$orderrow.send_price+$orderrow.buying_price+$orderrow.tax|string_format:"%.0f"}}</td>
							</tr>
						</tbody>
					</table>
				</div>

				<p class="button">
					<button type="button" id="btn_update" class="submit" onclick="if(!checkall()){return false;$(this).dialog('close');}"><span>更新</span></button>
				</p>
			</form>
		</section>
	</article>
</div>
<footer id="dashboard_footer">Copyright (C) SHIFT. / All rights reserved.</footer>
</body>
</html>